1. Field of the Invention
The present invention relates generally to an improved data processing system and in particular to the transformation of computer usable program code. Still more particularly, the present invention relates to transforming code to remove or modify inner classes present in a computer program written in an object-oriented computer programming language.
2. Description of the Related Art
Object-oriented programming languages are ubiquitous in modern programming. Object-oriented programs are used in computers, cell phones, personal digital assistants, games, and all manner of electronic goods to implement functionality desired by users. Many object-oriented languages are used to create these programs. Examples of object-oriented programming languages include JAVA, C++, C#, and many others.
Object-oriented programming (OOP) is a programming paradigm that uses “objects” and their interactions to design applications and computer programs. Object-oriented programs may be seen as a collection of cooperating objects, as opposed to a traditional view in which a program may be seen as a list of instructions to the computer. In object-oriented programming, each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent machine with a distinct role or responsibility.
Some basic concepts in object oriented programming include the notions of “class,” “object,” and “method.” Many other concepts exist in object-oriented programming, though these three provide a fundamental understanding of the overall nature of an object-oriented program.
A class defines the abstract characteristics of a thing, or object. The abstract characteristics include the thing's characteristics, such as its attributes, fields or properties, and the thing's behaviors, such as the things the object can do or methods or features of the thing. For example, the class Cat would consist of traits shared by all cats, such as breed and fur color (characteristics), and the ability to meow (behavior). Classes provide modularity and structure in an object-oriented computer program. The code for a class should be relatively self-contained. Collectively, the properties and methods defined by a class are called members.
An object is a particular instance of a class. The class of Cat defines all possible cats by listing the characteristics and behaviors they can have. For example, the object Fluffy is one particular cat, with particular versions of the characteristics. A Cat has fur; Fluffy has brown-and-white fur. The object Fluffy is an instance of the Cat class. The set of values of the attributes of a particular object is called the state of the object. The object comprises state and the behaviour that is defined in the object's class.
A method is an object's abilities. For example, Fluffy, being a Cat, has the ability to meow. Thus, meow ( ) is one of the methods of Fluffy. Fluffy may have other methods as well, for example run ( ), eat ( ), or pounce ( ). Within the program, using a method typically should only affect one particular object. For example, all Cats can pounce, one particular cat should pounce.
Object oriented programs can have outer classes and inner classes. An inner class is a class that is defined within, or as part of, the outer class. For example, a computer program may have the outer class, such as “Animal.” This outer class can include an inner class, such as “Cat.”
In some object-oriented programming languages, such as JAVA, an inner class can be an anonymous inner class. An anonymous inner class is an inner class that is not directly named in the computer program. Instead, the inner class “implicitly” exists and is processed accordingly upon execution of the program.
Inner classes and anonymous inner classes are a convenient way for program developers to implement “callbacks,” “event listeners,” or other desirable features of a program, in which information is transferred between objects. However, using these inner classes and anonymous inner classes has a price in terms of the performance overhead of loading the inner classes, the memory required to store the inner classes, and the extra-run-time footprint required to implement the inner classes. In the case of JAVA, even if these inner classes are not loaded, the presence of these inner classes increases the time required to search through a larger JAR (JAVA Archive) file.
In many cases, the performance penalty of these inner classes is small. However, for programs designed for electronic devices with very limited processing power and memory, such as cell phones, every possible space savings and performance enhancement of a final program can be desirable.